package com.jie.controller;



import com.jie.annotation.OptLog;
import com.jie.response.RespBean;
import com.jie.service.IUserExerciseService;
import com.jie.vo.ConditionVO;
import com.jie.vo.UserExerciseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import static com.jie.constants.OptTypeConst.*;

/**
 * <p>
 * 用户锻炼表 前端控制器
 * </p>
 *
 * @author jie
 * @since 2024-04-20
 */
@Api(tags = "用户锻炼信息模块")
@RestController
@RequestMapping("/user-exercise")
public class UserExerciseController {
    //分页查询当前用户锻炼的全部信息
    @Autowired
    private IUserExerciseService iUserExerciseService;
    @ApiOperation("查询当前用户锻炼的全部信息")
    @GetMapping("/get/userExerciseInfoById/{userId}")
    public RespBean<?> getUserExerciseInfoById(@PathVariable("userId") Integer userId){
        return RespBean.success("查询成功",iUserExerciseService.getUserExerciseInfoById(userId));
    }
    @ApiOperation("训练成功后调用这个接口可以使得用户经验值+10并且人数+1")
    @GetMapping("/add/userExerciseInfo/{topicId}")
//    @RedisCount(optSportType = RedisCountConst.SPORT_PARTICIPANT_NUMBER)
    public RespBean<?> addUserExerciseInfo(Integer topicId){
        return RespBean.success("训练成功",iUserExerciseService.addUserExerciseInfo(topicId));
    }
    @ApiOperation("用户训练专题接口，调用就是开始运动，会记录进度条")
    @PostMapping("/addOrUpdate/userExerciseInfo")
    @OptLog(optType=SAVE_OR_UPDATE)
    public RespBean<?> addUserExerciseInfo(@RequestBody UserExerciseVO userExerciseVO){
        //更新或添加
        Boolean flag=iUserExerciseService.addSportUserExerciseInfo(userExerciseVO);
        return RespBean.success("用户训练成功",flag);
    }

}

